// ajax post
function submitForm(url){

    // Data detection to prevent script-injected XSS attacks
    console.log($('form[class = "moduleBox"]').serialize().toString());

    let postDataStr = JSON.parse(JSON.stringify($('form[class = "moduleBox"]').serialize()));
    postDataStr = postDataStr.toString();

    let spacesDetect = '';
    let addDetect = '';
    let re = /select|update|delete|truncate|join|union|exec|insert|drop|count|'|"|;|>|</i;

    // Detect whether the data has abnormal data segments, determine whether
    // there is SQL code or html tags (to prevent the introduction of js through html)
    if (re.test(postDataStr)){
        alert("Please do not enter special characters or SQL keywords in the parameters!");

        return "special characters";
    }

    console.log($('*[name="passWordRegister"]').val());
    console.log($('*[name="passWordAgain"]').val());

    $.ajax({
        type: "POST",
        url: '/' + url,
        // data: JSON.parse({cont:data})
        dataType: "json",
        data: $('form[class = "moduleBox"]').serialize(),
        success: function (res) {
            console.log(res.cont.toString());
        },
        error:function(err){
            console.log("ajax status : " + err.status);
            console.log("ajax : " + err.statusText);
        }
    });

    // Feedback and page jump
    alert("Successful Operation *^____^*");
    if (url === 'userSetting') {
        window.location.href = "/userSetting";
    }
    else if (url === 'missionCenter') {
        window.location.href = "/missionCenter";
    }
    else {
        window.location.href = "/";
    }

    return false;
}